{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# -*- coding:utf-8 -*-\n",
    "class Solution:\n",
    "    # array 二维列表\n",
    "    def Find(self, target, array):\n",
    "        length = len(array)\n",
    "        width = len(array[0])\n",
    "        print(length, width)\n",
    "        print(array[0][1])\n",
    "        \n",
    "        # 从左下角到右上角查找，时间复杂度2n\n",
    "        #########width######[end]\n",
    "        ########################l\n",
    "        ########################e\n",
    "        ########################n\n",
    "        ########################g\n",
    "        ########################t\n",
    "        ########################h\n",
    "        #[begin]#################\n",
    "        l = length-1\n",
    "        w = 0\n",
    "        print(array[l][w])\n",
    "        while (l > 0 and w < width):\n",
    "#             print(array[l][w])\n",
    "            if array[l][w] == target:\n",
    "                return True\n",
    "            elif array[l][w] < target:\n",
    "                w += 1\n",
    "            else:\n",
    "                l -= 1\n",
    "        \n",
    "        return False\n",
    "        # write code here\n",
    "        \n",
    "        \n",
    "target, array = 7,[[1,2,8,9],[2,4,9,12],[4,7,10,13],[6,8,11,15]]\n",
    "Solution().Find(target, array)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
